package com.fyyg.wechat.util.message;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.jms.JmsException;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

import com.fyyg.wechat.util.SpringContextHolder;

public class MessageQueue {
	
    
	
	public static void addMessageQueu(final String message){
		JmsTemplate jmsTemplate;
		Destination destination;
		try {
			jmsTemplate =  SpringContextHolder.getBean("jmsTemplate");
			destination = SpringContextHolder.getBean("queueDestination");
			
			jmsTemplate.send(destination, new MessageCreator() {   
			    public Message createMessage(Session session) throws JMSException {   
			        return session.createTextMessage(message);   
			    }   
			});
		} catch (JmsException e) {
			System.out.println("发送错误"+e);
		} finally{
			jmsTemplate=null;
			destination=null;
		}
	}
	

}
